package org.extdev.libraries.ltr;

import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;

import org.extdev.libraries.ltr.LTR;

import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.ptr.IntByReference;

public interface LTRAPILibrary extends Library {
	/**
	 * inicilize ltr struct
	 * @param ltr struct by reference
	 * @return error codes
	 */
	int LTR_Init(LTR.ByReference ltr);
	/**
	 * use it to open your connection to ltr
	 * @param ltr struct by reference
	 * @return error codes
	 * @see org.extdev.libraries.ltr#LTR LTR struct;
	 */
	int LTR_Open(LTR.ByReference ltr);
	/**
	 * use it to close your connection to ltr
	 * @param ltr struct by reference
	 * @return error codes
	 */
	int LTR_Close(LTR.ByReference ltr);
	/**
	 * use it to check connection to your ltr module 
	 * @param ltr struct by reference
	 * @return error codes
	 */
	int LTR_IsOpened(LTR.ByReference ltr);
	/**
	 * 
	 * @param ltr
	 * @param crateSerialNo
	 * @return
	 */
	int LTR_GetCrates(LTR.ByReference ltr, ByteBuffer crateSerialNo);
	/**
	 * 
	 * @param ltr
	 * @param moduleID
	 * @return
	 */
	int LTR_GetCrateModules(LTR.ByReference ltr, ShortBuffer moduleID);
	/**
	 * 
	 * @param ltr
	 * @param data
	 * @param tmark
	 * @param size
	 * @param timeout
	 * @return
	 */
	int LTR_Recv(LTR.ByReference ltr, IntBuffer data, IntBuffer tmark, int size, int timeout);
	/**
	 * 
	 * @param ltr
	 * @param priority
	 * @return
	 */
	int LTR_GetServerProcessPriority(LTR.ByReference ltr, IntByReference priority);
	/**
	 * 
	 * @param ltr
	 * @param priority
	 * @return
	 */
	int LTR_SetServerProcessPriority(LTR.ByReference ltr, int priority);
	/**
	 * 
	 * @param ltr
	 * @param level
	 * @return
	 */
	int LTR_GetLogLevel(LTR.ByReference ltr, IntByReference level);
	/**
	 * 
	 * @param ltr
	 * @param level
	 * @param permanent
	 * @return
	 */
	int LTR_SetLogLevel(LTR.ByReference ltr, int level, boolean permanent);
	/**
	 * 
	 * @param ltr
	 * @return
	 */
	int LTR_ServerRestart(LTR.ByReference ltr);
	/**
	 * 
	 * @param ltr
	 * @return
	 */
	int LTR_ServerShutdown(LTR.ByReference ltr);
	/**
	 * 
	 * @param ltr
	 * @param version
	 * @return
	 */
	int LTR_GetServerVersion(LTR.ByReference ltr, IntByReference version);
	
	LTRAPILibrary instance = (LTRAPILibrary) Native.loadLibrary("ltrapi", LTRAPILibrary.class);
	LTRAPILibrary synchronizedInstance = (LTRAPILibrary) Native.synchronizedLibrary(instance);
}
